#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
vector<pair<int,int>> table[N];//邻接表,pair是邻接点和边的序号

int n,m;
int fa[N][20];//fa[i][j]表示i往上2^j层的父节点
int dep[N];

int edge[N];
int vertex[N];

int lca(int x,int y)
{
	if(dep[x]<dep[y]) swap(x,y);
	for(int i=19;i>=0;i--)
	{
		if(dep[x]-dep[y]>=(1<<i))
		{
			x=fa[x][i];
		}
	}
	if(x==y) return x;
	
	for(int i=19;i>=0;i--)
	{
		while(fa[x][i]!=fa[y][i])
		{
			x=fa[x][i];
			y=fa[y][i];
		}
	}
	return fa[x][0];
}
void dfs_lca(int u,int father)
{
	dep[u]=dep[father]+1;
	fa[u][0]=father;
	for(auto& e:table[u])
	{
		if(e.first==father) continue;//递归下去不死循环的关键
		
		dfs_lca(e.first,u);
	}
}

void dfs(int u,int father)
{
	for(auto&e:table[u])
	{
		if(e.first==father) continue;
		
		dfs(e.first,u);
		vertex[u]+=vertex[e.first];
		edge[e.second]+=vertex[e.first];
	}
	
}
int main()
{

	cin>>n>>m;
	for(int i=1;i<=n-1;i++)
	{

		int x,y;
		cin>>x>>y;
		table[x].push_back({y,i});
		table[y].push_back({x,i});
	}
	//cout<<55<<endl;


	//cout<<55<<endl;

	dfs_lca(1,0);
	//cout<<55<<endl;

	for(int i=1;i<=19;i++)
	{
		for(int u=1;u<=n;u++)
		{
			fa[u][i]=fa[fa[u][i-1]][i-1];
		}
		
	}
	//cout<<55<<endl;

	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		vertex[a]++;
		vertex[b]++;
		vertex[lca(a,b)]-=2;
	}

	dfs(1,0);//父亲的作用就是不会死循环
    int tmp=-1;
	for(int i=1;i<=n-1;i++)
	{
        //cout<<"i:"<<i<<"   edge:"<<edge[i]<<endl;
		if(edge[i]==m)
		{
			tmp=i;
		}
	}
    cout<<tmp;

	
	
	
	
	return 0;
}